<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>总数中的失败相关详细信息</title>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/show.js"></script>
<link href="<%=request.getContextPath()%>/fare/css/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/fare/js/jquery-1.6.4.min.js"></script>
<link href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath() %>/fare/css/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<script src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>

    
     <script type="text/javascript">
     var manager;
     var columns=[ 
  	 			{  display : '序号',	width:  40, 
  	 				render: function(data, index) { return (this.options.page-1)*this.options.pageSize+index+1;}
  	 		    },
  	 		   /*  {display : '航段',width : 180,name : 'leg'}, */
  	 		 { display : '航班日期',width : 85,name : 'flightDate',format: 'yyyy-MM-dd'}, 
  	 			/* {display : '查看详情',width : 70,
  	 				render: function (record, rowindex, value, column) {
  	 					return "<a href=\"javaScript:open_HBase_detail(\'"+record.sourceRowkey+"\');\">查看详情</a>";
  	 				   }
  	 			}, */
  	 			{display : '流量大小(m)', width : 100,
  	 				render: function (record, rowindex, value, column){
 					 	return (record.allbyteLength/(1024*1024)).toFixed(2);
 					 }
  	 			},
  	 			{display : '总次数', width : 100,name : 'total'},
  	 			{display : '成功次数', width : 100,name : 'successNum'},
  	 			{display : '失败次数', width : 100,name : 'failNum'},
  	 			{ display:'成功率',width: 70,align:'center',
  	 				render:function (row){
  	 					if(row.total==0)
  	 						return "<b style=\'color:red\'>"+"0%"+"</b>";
  	 					else if(row.successNum/row.total<0.5)
  	 						return "<b style=\'color:red\'>"+Math.round(row.successNum/row.total * 1000)/10+"%"+"</b>";
  	 					else
  	 						return "<b style=\'color:green\'>"+Math.round(row.successNum/row.total * 1000)/10+"%"+"</b>";
  	 				}
  	 			},
  	 			{ display: '状态统计', columns:
  	 				[
  	 				{ display: '抓取失败', name: 'secondFail',width:60,name:'secondFail' },
  	 			   { display: '解析失败', name: 'thirdFail',width:60, name:'thirdFail'},
  	 				 
  	 			   { display: '其他失败', name: 'forthFail',width:60, name:'forthFail'},
  	 				{ display: '等待中', name: 'waiting',width:60, name:'waiting'	},
  	 				
  	 				{ display: '执行中', name: 'working',width:60, name:'starting'}
  	 				]
  	 			},
  	 			{ display: '耗时统计', columns:
  	 				[
					{display:  '执行最大时间(秒)',width : 100,name:'maxTime'},
					{display:  '执行最小时间(秒)',width : 100,name:'minTime'},
					{display : '执行平均时间(秒)',width : 100,	name : 'avgTime'}
  	 				]
  	 			}
  	 			
  	 		//	{ display : '返程日期',width : 85,name : 'returnGrabDate',format: 'yyyy-MM-dd'}, 
  	 		//	{display : '执行时长',width : 80,	name : 'wasteTime'},
  	 			/* { display : '执行开始时间',width : 130,name : 'startTime',type: 'date',format: 'yyyy-MM-dd hh:mm:ss',
  	 				p:{showTime: true}	
  	 			},
  	 			{ display : '执行结束时间',width : 130,name : 'endTime',type: 'date',format: 'yyyy-MM-dd hh:mm:ss',
  	 				p:{showTime: true}	
  	 			},
  	 			{ display : '抓取日志',width : 260,	name : 'remarks'} */
  	 			];
     
        $(function () {
        	var grabchannelID=GetQueryString("grabchannelID");
        	var grabdate=GetQueryString("grabdate");
        	var fromCity=GetQueryString("fromCity");
        	var toCity=GetQueryString("toCity");
			var url="<%=request.getContextPath() %>/taskRecordAction!findTotalAllDetailInfo.action?grabdate="+grabdate+"&grabchannelID="+grabchannelID
					+"&fromCity="+fromCity+"&toCity="+toCity;
        	   $("#maingrid").ligerGrid({
        		   columns : columns,
       		       title:'任务状态详细信息',
       		       showTitle:true,
       		 	   height:'100%',
  		           usePager: false,
	  		       url:url,
			       width: '100%',
  	               onAfterShowData: function(){mergecell("#maingrid", "c102");
  	                        $("tr",$(manager)).each(function ()
  	                        {
  	                            $(this).mouseover(function() {$(this).css("cursor","pointer"); $(this).ligerTip({ content: "右键查看本条详细" });}); 
  	                            $(this).mouseout(function() {$(this).ligerHideTip({ content: $(this).text() });} );                                                                 
  	                        });
  	             },allowUnSelectRow:true,
  	             onRClickToSelect:true,onContextmenu : function (parm,e)
  	                {
  	            	 	bstime = parm.data.grabdate;
  	            	 //	leg = parm.data.leg;
  	            	 	formCity=parm.data.fromCity;
  	            	 	toCity=parm.data.toCity;
  	                    //menu.show({ top: e.pageY, left: e.pageX});
  	                    return false;
  	                }
        	 	});   
        });
        
        function GetQueryString(name)  
        {  
            var reg = new RegExp("(^|&)"+name+"=([^&]*)(&|$)");  
            var r= window.location.search.substr(1).match(reg);  
            if (r!=null) return unescape(r[2]);return null;  
        }        
        
        function open_HBase_detail(sourceRowKey){
        	if($.trim(sourceRowKey).length>0){
        		 $.ajax({
        			  url: "<%=request.getContextPath() %>/taskRecordAction!fetchContent.action?sourceRowKey="+$.trim(sourceRowKey),
        			  cache: false,
        			  success: function(data){
        				  //var OpenWindow=window.showModalDialog("test.html?data="+data, data, "dialogWidth=200px;dialogHeight=100px"); 
        				  //var OpenWindow=window.showModalDialog("http://www.bejson.com/go.html?u=http://www.bejson.com/jsonview2/","JSON详情", "  width=4000,toolbar=yes,scrollbars=yes,menubar=yes",false);
        				  var OpenWindow=window.open("test.html", "HBase详情", "height=1000,width=4000,toolbar=yes,scrollbars=yes,menubar=yes",false); 
        				  OpenWindow.document.write(data) ;
        			  } 
        			});
        	}else{
        		 $.ligerDialog.warn('HBase的sourceRowKey为空');
        	}
        }
        
        function mergecell(gridid, columnid) //参数:表格id和列索引关键字，根据表格具体值来动态合并单元格
        {
            var i, j, k, x;
            i = -1; k = 1; j = ""; x = 0;
            var cellname = "";

            $("td[id$='|" + columnid + "']", gridid).each(
                   function() {
                       if (j == $("div", this).text()) {
                           $(this).addClass("l-remove");
                           k++;
                           $("td[id='" + cellname + "']", gridid).attr("rowspan", k.toString());
                       }
                       else {
                           j = $("div", this).text();
                           var a = $(this);
                           cellname = a.attr("id"); //得到点击处的id                            
                           k = 1;
                           x = i;
                       }
                       i++;
                   });
            $(".l-remove").remove();
        }
    </script>            
    <script>
	function reload(){
		window.location.reload();
	}
	function back(){
		history.go(-1);
	}
	function closewin(){
		if (confirm("您确定要关闭本页吗？")){
			window.opener=null;
			window.open('','_self');
			window.close();
			}
			else{}
	}
	function returnF(){
		var urls="fswInfoAction!getStatisticsTaskReport.action";
		window.location.href=urls;
	}
</script>    
</head>

<body style="padding:10px">
	<div id="reseachBy" >
		<table width="100%" cellpadding="0" cellspacing="5">
			<tr>
				<td align="left" width="95%">
					抓取渠道:&nbsp;&nbsp; ${grabChannel}
				
					<% String grabchannel=request.getParameter("grabchannel"); %>
					<%=new String(grabchannel.getBytes("ISO-8859-1"),"utf-8")%>
					
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					 航班抓取日期:&nbsp;&nbsp;<%=request.getParameter("grabdate")%>
					 
					 
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					 航段:&nbsp;&nbsp;
					 <% String leg=request.getParameter("leg"); %>
					<%=new String(leg.getBytes("ISO-8859-1"),"UTF-8")%>
				</td>
				<td>
					<!-- <input type="button" onclick="back()" value="返回上一页"/> -->
					<!-- <input type="button" onclick="reload()" value="刷新"/> -->
					<!--  <input type="button" onclick="closewin()" value="关闭"/> -->
					<!-- <input type="button" onclick="returnF()"  value="返回首页"/> -->
				</td> 
				
			</tr>
			</table>
		</div>

    <div id="maingrid" style="margin-top: 0px">
    </div>
    <div id="results" style="margin-top: 20px">
    </div>
</body>
</html>
